package com.tool;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class Login {
    @Pointcut("execution(public * com.service.*.*(..))")
    private void pt1(){};
    @Before(value = "pt1()")
    public void beforelog(){
        System.out.println("beforelog");
    }
    @After(value = "pt1()")
    public void afterlog(){
        System.out.println("afterlog");
    }
    @AfterReturning(value = "pt1()")
    public void afterrunnerlog(){
        System.out.println("afterrunnerlog");
    }
    @AfterThrowing(value = "pt1()")
    public void afterthrowlog(){
        System.out.println("afterthrowlog");
    }
    @Around(value = "pt1()")
    public Object aroundlog(ProceedingJoinPoint point){
        Object value=null;
        try {
            System.out.println("环绕前");
            Object[]args = point.getArgs();
            value=point.proceed(args);

            System.out.println("环绕后");
            return value;
        } catch (Throwable throwable) {
            throw new RuntimeException("af");
        }
    }
}
